package com.spingbootes.kizuki.es;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDate;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class IndexInfo{
    private String indexPrefix;
    private int beginYear;
    private int endYear;

    public List<String> getIndexs(){
        if(endYear <= 0) {
            endYear = LocalDate.now().getYear();
        }
        return IntStream.rangeClosed(beginYear, endYear)
                .mapToObj(index -> ESConfig.INDEX_PREFIX + index)
                .collect(Collectors.toList());
    }
}
